package com.softserveinc.autorent.controller;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import com.softserveinc.autorent.manager.UserEJB;
import com.softserveinc.autorent.model.CarVendor;
import com.softserveinc.autorent.model.User;



@ManagedBean
@SessionScoped
public class UserMB implements Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -7736986230655715942L;
	@EJB
	private UserEJB userEJB;
	private User user = new User();
	private List<User> list = new ArrayList<User>();
	
	public List<User> getList() {
    	list = userEJB.findAll();    	
		return list;
	}
	public String doCreate()
	{
		userEJB.create(user);
		return "user_list.xhtml";
	}	
	public String doUpdate()
	{
		userEJB.update(user);
		return "user_list.xhtml";		
	}	
	public String doDelete()
	{
		userEJB.delete(user);
		return "user_list.xhtml";
	}
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	public void setList(List<User> list) {
		this.list = list;
	}	
}
